package com.tetris.project;

import android.content.Context;
import android.media.MediaPlayer;

public class Music {
	private MediaPlayer mp = null;
	private MediaPlayer mp2 = null;
	Context myContext;
	
	public Music(Context context){
		myContext = context;
	}
	
	/** first stops any other song currently playing */
	public void play(int resource) {
		stop();
		mp =  MediaPlayer.create(myContext, resource);
		mp.setLooping(true);
		mp.start();
	}
	
	/** stop song currently played */
	public void stop() {
		if (mp != null) {
			mp.stop();
			mp.release();
			mp = null;
		}		
	}	
	
	public void playButtonSound(int resource) {
		mp2 = MediaPlayer.create(myContext, resource);
		mp2.setLooping(false);
		mp2.start();
	}
}